home *** CD-ROM | disk | FTP | other *** search
- /****i* SOURCE_FILE/INFO
- *
- * NAME
- * Exception.js
- *
- * USAGE
- * Part of Netobjects JavaScript Library.
- *
- * COPYRIGHT
- * Copyright ⌐ 2000-2005 Website Pros, Inc.
- * All Rights Reserved.
- *
- * This is an unpublished work protected by Website Pros, Inc.
- * as a trade secret, and is not to be used or disclosed except as
- * expressly provided in a written license agreement executed by
- * you and Website Pros, Inc.
- *
- * <copyright@websitepros.com>
- *
- * NOTES
- * JavaScript code.
- *
- *****/
-
- if (!IS.isModuleInitialized("IS.NOF.UTIL.Exception"))
- {
-
- /****h* NOF_JavaScript_Library/NOF.UTIL.Exception
- *
- * NAME
- * NOF.UTIL.Exception
- *
- * DESCRIPTION
- * Error and exception handling.
- *
- ****/
- /**
- * Constructor
- * @param msg - identifier of this exception object
- * @param fileName - path to file (or NS-complete class name) from which exception occured.
- * Also, the method name should be added to this argument.
- * @param lineNumber - the line in script
- **/
- function UTIL_Exception( /*String*/ msg, /*String*/ fileName, /*int*/ lineNumber) {
- this.__proto__ = UTIL_Exception.prototype;
-
- this.name = "Exception";
- this.message = msg;
- this.fileName = fileName;
- this.lineNumber = lineNumber;
- }{
- var method = UTIL_Exception.prototype;
-
- /**
- * Returns the name of the exception.
- **/
- method.getName = function () { return this.name; }
-
- /**
- * Returns the message of the exception.
- **/
- method.getMessage = function () {
- return this.message;
- }
-
- /**
- * Returns the string representation of the exception.
- **/
- method.toString = function () {
- var tmpstr = "[" + this.name + ": " + this.message;
- if (this.fileName != null) {
- tmpstr += NOF.App.getLineBreak() + " at (" + this.fileName;
- if (this.lineNumber != null) {
- tmpstr += ":" + this.lineNumber;
- }
- tmpstr += ")";
- }
- tmpstr += "]";
- return tmpstr;
- }
- }
-
- UTIL.__proto__.Exception = UTIL_Exception;
- //TODO: remove it from NOF NS.
- //NOF.__proto__.Exception = UTIL.Exception;
-
- /****h* NOF_JavaScript_Library/NOF.UTIL.ChainedException
- *
- * NAME
- * NOF.UTIL.ChainedException
- *
- * DESCRIPTION
- * Chained Error and exception handling.
- *
- ****/
- /**
- * Constructor
- * @param targetE - target Exception
- * @param msg - identifier of this exception object
- * @param fileName - path to file (or NS-complete class name) from which exception occured
- * @param lineNumber - the line in script
- **/
- function UTIL_ChainedException(/*NOF.UTIL.Exception*/ targetE, /*String*/ msg, /*String*/ fileName, /*int*/ lineNumber) {
- this.__proto__ = UTIL_ChainedException.prototype;
- this.SUPER(msg, fileName, lineNumber);
-
- this.name = "ChainedException";
- this.targetException = targetE;
- }
-
- UTIL_ChainedException.inherits(NOF.UTIL.Exception)
- {
- var method = UTIL_ChainedException.prototype;
- method.super_toString = method.toString;
- method.toString = function () {
- /*
- var sb = "[";
- sb += this.name + ": msg=";
- sb += this.message;
- if (this.targetException != null)
- sb += "; targetException=" + this.targetException.getMessage();
- sb += "]";
- return sb;
- */
- var tmpstr = this.super_toString();
- tmpstr = tmpstr.substring(0, tmpstr.length - 1);
- if (this.targetException != null) {
- tmpstr += "; targetException=" + this.targetException.toString();
- }
- tmpstr += "]";
- return tmpstr;
- }
-
- method.getMessage = function () {
- var superMsg = this.message;
- var targetMsg = (this.targetException != null)
- ? this.targetException.getMessage()
- : null;
-
- var msg = ((superMsg == null || superMsg.length <= 0)
- && (targetMsg != null && targetMsg.length > 0))
- ? targetMsg
- : superMsg;
-
- if (msg == null || msg.length <= 0) {
- msg = (this.targetException != null)
- ? this.targetException.toString()
- : this.toString();
- }
-
- return msg;
- }
-
-
- method.setTargetException = function (t) {
- this.targetException = t;
- }
-
- method.getTargetException = function () {
- return this.targetException;
- }
-
- method.getRootException = function () {
- return this.targetException != null ? this.targetException : this;
- }
- }
-
- UTIL.__proto__.ChainedException = UTIL_ChainedException;
-
-
- /****h* NOF_JavaScript_Library/NOF.UTIL.ConcurrentModificationException
- *
- * NAME
- * NOF.UTIL.ConcurrentModificationException
- *
- * DESCRIPTION
- * Concurrent Modification Error and Exception handling.
- *
- ****/
- /**
- * Constructor
- **/
- function UTIL_ConcurrentModificationException(/*NOF.UTIL.Exception*/ targetE, /*String*/ msg, /*String*/ fileName, /*int*/ lineNumber) {
- this.__proto__ = UTIL_ConcurrentModificationException.prototype;
- this.SUPER(msg, fileName, lineNumber);
-
- this.name = "ConcurrentModificationException";
- }
-
- UTIL_ConcurrentModificationException.inherits(NOF.UTIL.Exception);
- UTIL.__proto__.ConcurrentModificationException = UTIL_ConcurrentModificationException;
-
-
- /****h* NOF_JavaScript_Library/NOF.UTIL.AbstractMethodError
- *
- * NAME
- * NOF.UTIL.AbstractMethodError
- *
- * DESCRIPTION
- * Concurrent Modification Error and Exception handling.
- *
- ****/
- /**
- * Constructor
- **/
- function UTIL_AbstractMethodError(/*NOF.UTIL.Exception*/ targetE, /*String*/ msg, /*String*/ fileName, /*int*/ lineNumber) {
- this.__proto__ = UTIL_AbstractMethodError.prototype;
- this.SUPER(msg, fileName, lineNumber);
-
- this.name = "AbstractMethodError";
- }
-
- UTIL_AbstractMethodError.inherits(NOF.UTIL.Exception);
- UTIL.__proto__.AbstractMethodError = UTIL_AbstractMethodError;
- }